package team.knowers.qzhserver.common.config;

import org.redisson.api.RBloomFilter;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 布隆过滤器的配置
 * @author zcb
 * @date 2024/3/14 23：00
 */
@Configuration
public class BloomFilterConfig {
    @Bean
    @Qualifier("bloomFilterUsername")
    RBloomFilter<String> usernameBloomFilter(RedissonClient redissonClient){
        RBloomFilter<String> usernameBloomFilter =redissonClient.getBloomFilter("bloomFilterUsername");
        usernameBloomFilter.tryInit(1000,0.003);
        return usernameBloomFilter;
    }
    @Bean
    @Qualifier("bloomFilterUserId")
    RBloomFilter<String> userIdBloomFilter(RedissonClient redissonClient){
        RBloomFilter<String> userIdBloomFilter =redissonClient.getBloomFilter("bloomFilterUserId");
        userIdBloomFilter.tryInit(1000,0.003);
        return userIdBloomFilter;
    }

}
